package com.csc.controller;

import com.csc.dto.StuParam;
import com.csc.entity.Student;
import com.csc.mapper.StudentMapper;
import com.csc.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import java.util.List;


@RestController
@RequestMapping("/student")
@CrossOrigin
public class StudentController {
    @Autowired
    private StudentService studentService;

    @RequestMapping("/list")
    public List<Student> list(@RequestBody StuParam stuParam) {
        return studentService.getList(stuParam);
    }

    @RequestMapping("/add")
    public String add(@RequestBody Student student) {
        return studentService.add(student);
    }

    @RequestMapping("/detail")
    public Student detail(Integer studentId) {
        return studentService.findById(studentId);
    }

    @RequestMapping("/update")
    public String update(@RequestBody Student student) {
        return studentService.update(student);
    }

    @RequestMapping("/delete")
    public String delete(Integer studentId) {
        return studentService.delete(studentId);
    }

}
